package platform

import "talent.com/agency_im/conf/g"

func GetPlatformByID(id uint64) (*Platform, error) {

	var (
		platform Platform
		err      error
	)
	if err = g.ORM.First(&platform, id).Error; err != nil {
		return nil, err
	}
	return &platform, err
}

func GetPlatformByAppID(appId string) (*Platform, error) {

	var (
		platform Platform
		err      error
	)
	if err = g.ORM.Where("app_id = ?", appId).First(&platform).Error; err != nil {
		return nil, err
	}
	return &platform, err
}

func GetPlatformByPayMchID(payMchID uint64) (*Platform, error) {

	var (
		platform Platform
		err      error
	)
	if err = g.ORM.Where("pay_mch_id = ?", payMchID).First(&platform).Error; err != nil {
		return nil, err
	}
	return &platform, err
}
